package com.yourvote.dao.impl;

import com.yourvote.dao.BaseDao;
import com.yourvote.dao.Dao;

import javax.persistence.EntityManager;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: pavlo.fedyna
 * Date: 10/25/12
 * Time: 11:51 AM
 * To change this template use File | Settings | File Templates.
 */
public class BaseDaoImpl implements BaseDao{
    EntityManager entityManager = Dao.INSTANCE.getEm();

    @Override
    public EntityManager getEM() {
        return entityManager;
    }

    public void persist(Object o){
        getEM().persist(o);
    }

    public List getAll(String query){
        return getEM().createQuery(query).getResultList();
    }


    public EntityManager getEntityManager() {
        return entityManager;
    }

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }


}
